package org.example.app.bean;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 店铺销售数据累加器 - 用于Flink聚合操作
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ShopSalesAccumulator {
    
    // 店铺基本信息
    public String shopId;
    public String shopName;
    public String cityId;
    public String cityName;
    public String provinceId;
    public String provinceName;
    public String shopType;
    public String shopLevel;
    
    // 累计度量值
    public Double totalSalesAmount = 0.0;
    public Long totalSalesCount = 0L;
    public Long totalVisitorCount = 0L;
    public Long productCount = 0L;
    public Double avgOrderValue = 0.0;
    public Double customerRating = 0.0;
    public Integer count = 0;
    
    // 窗口时间信息
    public Long windowStart;
    public Long windowEnd;
    
    /**
     * 重置累加器
     */
    public void reset() {
        this.totalSalesAmount = 0.0;
        this.totalSalesCount = 0L;
        this.totalVisitorCount = 0L;
        this.productCount = 0L;
        this.avgOrderValue = 0.0;
        this.customerRating = 0.0;
        this.count = 0;
    }
    
    /**
     * 计算平均订单价值
     */
    public void calculateAvgOrderValue() {
        if (totalSalesCount > 0) {
            this.avgOrderValue = totalSalesAmount / totalSalesCount;
        }
    }
}